<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-uu.html" />
<link rel="prev" href="module-binascii.html" />
<link rel="parent" href="netdata.html" />
<link rel="next" href="module-uu.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>7.14 quopri -- Encode and decode MIME quoted-printable data</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.13 binascii  "
  href="module-binascii.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7. internet Data Handling"
  href="netdata.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.15 uu  "
  href="module-uu.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-binascii.html">7.13 binascii  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="netdata.html">7. Internet Data Handling</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-uu.html">7.15 uu  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h1><a name="SECTION0091400000000000000000">
7.14 <tt class="module">quopri</tt> --
         Encode and decode MIME quoted-printable data</a>
</h1>

<p>
<a name="module-quopri"></a>

<p>
This module performs quoted-printable transport encoding and decoding,
as defined in <a class="rfc" id='rfcref-99828' xml:id='rfcref-99828'
href="http://www.faqs.org/rfcs/rfc1521.html">RFC 1521</a>: ``MIME (Multipurpose Internet Mail
Extensions) Part One: Mechanisms for Specifying and Describing the
Format of Internet Message Bodies''.  The quoted-printable encoding is
designed for data where there are relatively few nonprintable
characters; the base64 encoding scheme available via the
<tt class="module"><a href="module-base64.html">base64</a></tt> module is more compact if there are many such
characters, as when sending a graphics file.
<a id='l2h-1638' xml:id='l2h-1638'></a><a id='l2h-1643' xml:id='l2h-1643'></a>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1639' xml:id='l2h-1639' class="function">decode</tt></b>(</nobr></td>
  <td><var>input, output</var><big>[</big><var>,header</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Decode the contents of the <var>input</var> file and write the resulting
decoded binary data to the <var>output</var> file.
<var>input</var> and <var>output</var> must either be file objects or objects that
mimic the file object interface. <var>input</var> will be read until
<code><var>input</var>.readline()</code> returns an empty string.
If the optional argument <var>header</var> is present and true, underscore
will be decoded as space. This is used to decode
``Q''-encoded headers as described in <a class="rfc" id='rfcref-99831' xml:id='rfcref-99831'
href="http://www.faqs.org/rfcs/rfc1522.html">RFC 1522</a>: ``MIME (Multipurpose Internet Mail Extensions)
Part Two: Message Header Extensions for Non-ASCII Text''.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1640' xml:id='l2h-1640' class="function">encode</tt></b>(</nobr></td>
  <td><var>input, output, quotetabs</var>)</td></tr></table></dt>
<dd>
Encode the contents of the <var>input</var> file and write the resulting
quoted-printable data to the <var>output</var> file.
<var>input</var> and <var>output</var> must either be file objects or objects that
mimic the file object interface. <var>input</var> will be read until
<code><var>input</var>.readline()</code> returns an empty string.
<var>quotetabs</var> is a flag which controls whether to encode embedded
spaces and tabs; when true it encodes such embedded whitespace, and
when false it leaves them unencoded.  Note that spaces and tabs
appearing at the end of lines are always encoded, as per <a class="rfc" id='rfcref-99833' xml:id='rfcref-99833'
href="http://www.faqs.org/rfcs/rfc1521.html">RFC 1521</a>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1641' xml:id='l2h-1641' class="function">decodestring</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>,header</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="function">decode()</tt>, except that it accepts a source string and
returns the corresponding decoded string.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1642' xml:id='l2h-1642' class="function">encodestring</tt></b>(</nobr></td>
  <td><var>s</var><big>[</big><var>, quotetabs</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="function">encode()</tt>, except that it accepts a source string and
returns the corresponding encoded string.  <var>quotetabs</var> is optional
(defaulting to 0), and is passed straight through to
<tt class="function">encode()</tt>.
</dl>

<p>
<div class="seealso">
  <p class="heading">See Also:</p>

  <dl compact="compact" class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-mimify.html">mimify</a></tt>:</b>
    <dd>General utilities for processing of MIME messages.
  </dl>
  <dl compact="compact" class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-base64.html">base64</a></tt>:</b>
    <dd>Encode and decode MIME base64 data.
  </dl>
</div>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.13 binascii  "
  href="module-binascii.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="7. internet Data Handling"
  href="netdata.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7.15 uu  "
  href="module-uu.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-binascii.html">7.13 binascii  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="netdata.html">7. Internet Data Handling</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-uu.html">7.15 uu  </a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
